Skip to content

Dataset match subdomain/v1 - #15058

Closed
antoineaboufayssal wants to merge 2 commits into
OISF:mainfrom
antoineaboufayssal:dataset-match-subdomain/v1
Closed

Dataset match subdomain/v1#15058
antoineaboufayssal wants to merge 2 commits into
OISF:mainfrom
antoineaboufayssal:dataset-match-subdomain/v1

Conversation

@antoineaboufayssal

Copy link
Copy Markdown
Contributor

Contribution style:

Our Contribution agreements:

Changes (if applicable):

  • I have updated the User Guide (in doc/userguide/) to reflect the changes made

Link to ticket: https://redmine.openinfosecfoundation.org/issues/8385

Describe changes:

  • add match subdomain option for datasets

Provide values to any of the below to override the defaults.

  • To use a Suricata-Verify or Suricata-Update pull request,
    link to the pull request in the respective _BRANCH variable.
  • Leave unused overrides blank or remove.

SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=

@codecov

codecov Bot commented Mar 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.62162% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.58%. Comparing base (6587e36) to head (2aa43ba).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15058      +/-   ##
==========================================
- Coverage   82.59%   82.58%   -0.01%     
==========================================
  Files         990      990              
  Lines      271761   271797      +36     
==========================================
+ Hits       224465   224468       +3     
- Misses      47296    47329      +33     
Flag Coverage Δ
fuzzcorpus 61.01% <21.62%> (-0.01%) ⬇️
livemode 18.34% <13.51%> (-0.02%) ⬇️
netns 18.38% <0.00%> (+0.01%) ⬆️
pcap 45.22% <0.00%> (-0.04%) ⬇️
suricata-verify 66.08% <21.62%> (-0.07%) ⬇️
unittests 58.82% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 20.951% (-58.4%) from 79.315%
when pulling 2aa43ba on antoineaboufayssal:dataset-match-subdomain/v1
into 6587e36 on OISF:main.

Comment thread src/detect-dataset.c
Comment thread src/detect-dataset.h
Dataset *set;
uint8_t cmd;
DatasetFormats format;
bool match_subdomain; /* walk up domain hierarchy on lookup */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: placing bool after uint8_t leads to a more efficient memory layout

Comment thread src/detect-dataset.c
{
for (uint32_t i = 1; i < data_len; i++) {
if (data[i] == '.') {
int r = DatasetLookup(set, data + i, data_len - i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should limit the number of calls to DatasetLookup in case someone tricks an input like .............................. many times

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could skip consecutive dots, then .............................. will have 0 lookups. But it wouldn't cover the case where the domain is like .a.a.a.a.a.a.a.a.a.a.a..... DNS names max at 253 bytes, so worst case is ~126 lookups. Is this fine? What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use this for buffers that come from other data, like http.host where there isn't necessarily a length limit enforced

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll add a skip for consecutive dots and a cap for the lookups. What's a reasonable cap?

@catenacyber catenacyber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work, looks good

Needs clang format fix apparently

Also the commit messages need to reference the ticket number

@catenacyber

Copy link
Copy Markdown
Contributor

And this also needs SV tests

@antoineaboufayssal

Copy link
Copy Markdown
Contributor Author

v2: #15073

@antoineaboufayssal
antoineaboufayssal deleted the dataset-match-subdomain/v1 branch July 31, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants